@section('title')
    我的钱包 @parent
@show

@section('subcontent')
{{ HTML::script('js/center/wallet.js') }}
<!-- 我的资料 -->

<div id="mainUserInfo">
	<div class="mod-main mod-comm lefta-box">
	    <div class="mt">
			<h3 class="curr">我的钱包</h3> 
	    </div>

	    <div style="overflow:hidden;padding:20px">
	    	<div class="limiticon"></div>
			<div class="limit">
				<p>账户余额 :<span style="color:#f7b84f"> {{$data['money']}} 元</span></p>

				<P>
					@if(Auth::user()->isVerifiedLawyer())
					<a href="{{ Route('center.lawyer.wallet.moneyin') }}">
						<span class="btn-bg-size" style=" margin-right:30px;">充值</span>
					</a>
					<a href="{{ Route('center.lawyer.wallet.moneyout') }}">
						<span class="btn-bg-size" >提现</span>
					</a>
					@else
					<a href="{{ Route('center.wallet.moneyin') }}">
						<span class="btn-bg-size" style=" margin-right:30px;">充值</span>
					</a>
					<a href="{{ Route('center.wallet.moneyout') }}">
						<span class="btn-bg-size">提现</span>
					</a>
					@endif
				</p>
			</div>
	    </div>
	    <div class="titlebg">交易记录</div>
	    
		<div id="tab">
			<div class="tabList">
				<ul>
					<li class="cur">最新交易记录</li>
					<li>充值记录</li>
					<li>提现记录</li>
				</ul>
			</div>
			<div class="tabCon">
				<ul  class="cur">
				
			    </ul>
			    <ul>
			    
			    </ul>
			    <ul>
			    
			    </ul>
			    
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
var jumpUrl = "{{Config::get('app.url')}}";
var oDiv = document.getElementById("tab");
var oLi = oDiv.getElementsByTagName("div")[0].getElementsByTagName("li");
var aCon = oDiv.getElementsByTagName("div")[1].getElementsByTagName("ul");
//交易记录
	var type = '';
	var getRecord = function(){
		$(".tabCon .cur li").remove();
		 var loading = '<li><div class="loading">加载中...</div></li>'; 
    	$(".tabCon .cur").append(loading);
		url = jumpUrl+"/wallet/record?type="+type;
		$.get(url,{},function(e){
		}, 'json').error(function(data){
		}).success(function(data){
			$(".loading").parent().remove();
			var obj = data.data;
			var str = '';
			if(obj.length ==0 ){
				str = '<div class="redtitle">你没有交易记录<div>';
			}
				
			for(var i=0; i<obj.length; i++){
				str+='<li>';
					str+='<span class="span1">'+obj[i].updated_at+'</span>'
					str+='<span class="span1">'+obj[i].description+'</span>'
					str+='<span class="span2">'+obj[i].direction+obj[i].sum+'</span>'
					str+='<span class="span2">'+obj[i].status+'</span>'
				str+='</li>';
			}
			$('.tabCon .cur').html(str);
			for(var j=0; j<obj.length; j++){
                  if (j%2 == 0) {
                  $(".tabCon .cur li").eq(j).css("background-color","#f0f0f0");
                    }
                }
		});
	}	
var timer = null;
	for (var i = 0; i < oLi.length; i++) {
	   oLi[i].index = i;
	   oLi[i].onclick = function() {
	      show(this.index);
	   }
	}
	//切换不同类型交易记录
	getRecord();

	function show(a) {
		index = a;
		var alpha = 0;
		for (var j = 0; j < oLi.length; j++) {
		    oLi[j].className = "";
		    aCon[j].className = "";
		    aCon[j].style.opacity = 0;
		    aCon[j].style.filter = "alpha(opacity=0)";
		}
		oLi[index].className = "cur";
		aCon[index].className = "cur";
	    switch(index){
	    	case 0:
	        	type = '';
	        break;
	        case 1:
	        	type = 'recharge';
	        break;
	        case 2:
	        	type = 'withdraw';
	        break;
	    }
	    getRecord();
	    clearInterval(timer);
	    timer = setInterval(function() {
	    	alpha += 2;
	        alpha > 100 && (alpha = 100);
	        aCon[index].style.opacity = alpha / 100;
	        aCon[index].style.filter = "alpha(opacity=" + alpha + ")";
	        alpha == 100 && clearInterval(timer);
	    },5)
	}
</script>
@show